<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <script type="text/javascript" src="/Public/js/jquery.min.js"></script>
        <script type="text/javascript" src="/Public/js/jquery.easyui.min.js"></script>
        <style type="text/css">
            body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
            #l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;}
            #r-result{height:100%;width:20%;float:left;}
        </style>
        <script type="text/javascript" src="http://map.qq.com/api/js?v=1"></script>
        <script charset="utf-8" src="http://open.map.qq.com/doc/js/MarkerPicker.js"></script>
        <title>设置覆盖物的显示与隐藏</title>
    </head>
    <body onload="init()">

        <div id="l-map"></div>
        <div id="r-result">
            <input type="text" id="buildingName" value=":<?php echo ($vo["BuildingName"]); ?>"/>
            <input type="text" id="buildingAddress" value=":<?php echo ($vo["BuildingAddress"]); ?>"/>
            <input type="button"  value="保存标注坐标" onclick="submitpoint()" />
        </div>
        <script type="text/javascript">
                    var marker = null;
                    var init = function() {
                    var center = new soso.maps.LatLng(<?php echo ($vo["Longitude"]); ?>, <?php echo ($vo["Latitude"]); ?>);
                            var map = new soso.maps.Map(document.getElementById("l-map"), {
                            center: center,
                                    zoomLevel: 15
                            }
                            );
                            marker = new soso.maps.Marker({
                            position: center,
                                    draggable: true,
                                    map: map
                            });
                            var contextMenu = new soso.maps.ContextMenuControl();
                            contextMenu.setMap(map);
                            contextMenu.addItem("放大", zoomIn);
                            contextMenu.addSeparator();
                            contextMenu.addItem("缩小", zoomOut);
                            contextMenu.addSeparator();
                            contextMenu.addItem("查看全国", zoomToMinLevel);
                            contextMenu.addTarget(map);
                            function zoomIn() {
                            map.zoomTo(map.getZoomLevel() + 1);
                            }
                    function zoomOut() {
                    map.zoomTo(map.getZoomLevel() - 1);
                    }
                    function zoomToMinLevel() {
                    map.zoomTo(4);
                    }
                    }

            function submitpoint() {
            if (marker == null) {
            alert("没有添加标注！");
            }
            else {
            var p = marker.getPosition();
            var buildingName=$('#buildingName').val();
            var buildingAddress=$('#buildingAddress').val();
            alert(buildingName);
                    $.post("<?php echo U('Map/SetBuildingPoint');?>", {Lon: p.lng, Lat: p.lat,BuildingName:buildingName,BuildingAddress:buildingAddress}, function(data) {
                    if (data == "y")
                    {
                    alert("保存成功！");
                    }
                    else
                    {
                    alert("保存失败！");
                    }

                    });
            }
            }

        </script>
      
    </body>
</html>